﻿Imports System.Windows.Forms

Public Class Dialog1

    Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'WebBrowser1.Visible = False
        WebBrowser1.Navigate("https://ic.dist113.org/campus/township.jsp")
    End Sub

    Private Sub waiting() Handles WebBrowser1.DocumentCompleted
        If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            If WebBrowser1.Url.Equals("https://ic.dist113.org/campus/township.jsp") Then

                WebBrowser1.Document.GetElementById("username").InnerText = Form1.TextBox1.Text
                WebBrowser1.Document.GetElementById("password").InnerText = Form1.TextBox2.Text
                SendKeys.Send(Chr(13))
            End If
            
        End If
    End Sub

    Private Sub WebBrowser1_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
        If WebBrowser1.Url.Equals("https://ic.dist113.org/campus/township.jsp?status=error") Then
            Form1.Show()
            Form1.Label3.Visible = True
            Me.Close()
        End If
        If WebBrowser1.Url.Equals("https://ic.dist113.org/campus/portal/main.xsl") Then
            Form2.Show()
            Me.Close()
        End If
    End Sub
End Class
